//
//  XWDetailTabVC.swift
//  PersonalContacts
//
//  Created by xiewei on 16/12/1.
//  Copyright © 2016年 xiewei. All rights reserved.
//

import UIKit

class XWDetailTabVC: UITableViewController {
    
    @IBOutlet weak var nameL: UITextField!
    @IBOutlet weak var telL: UITextField!
    var person: XWPerson?
    var completionCallBack: (() -> ())?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if person != nil {
            nameL.text = person?.name
            telL.text = person?.tel
        }
    }
    
    /// 保存修改后的信息
    @IBAction func saveInfo(_ sender: UIBarButtonItem) {
        if person == nil {
            person = XWPerson()
        }
        
        // 通过textField内容来修改XWPerson的属性
        person?.name = nameL.text
        person?.tel = telL.text
        
        
        completionCallBack?()
        _ = navigationController?.popViewController(animated: true)
    }
    deinit {
        print("\(#function)")
    }
}
